//
//  PituandateViewController.m
//  中皮网
//
//  Created by ios程序员 on 15/10/29.
//  Copyright (c) 2015年 ios程序员. All rights reserved.
//

#import "PituandateViewController.h"
#import "PTDate.h"
#import "PtDateView.h"
#import "XQJSView.h"
#import "OtherView.h"

@interface PituandateViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property (nonatomic ,strong) UICollectionView *collectionView;
@property (nonatomic ,strong) XQJSView *xqView;
@property (nonatomic ,strong) OtherView *otherView;
@end

@implementation PituandateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    self.scrollView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.scrollView];
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    _scrollView.contentSize = CGSizeMake(0, 600*HEIGH);

    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    /* 更改item 大小 默认（50 * 50） */
    flowLayout.itemSize = CGSizeMake(self.view.frame.size.width / 2-20, self.view.frame.size.width / 2 -20);
    /* 设置item 上下之间的距离（最小值）*/
    flowLayout.minimumLineSpacing = 5;
    /* 设置item 左右之间的距离（最小值） */
    flowLayout.minimumInteritemSpacing = 5;
    /* 设置距四边地距离 */
    flowLayout.sectionInset = UIEdgeInsetsMake(15, 15, 15, 15);
    /* 创建对象 */
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:flowLayout];
    /* 背景颜色默认是黑色 */
    /* 两个协议 */
    self.collectionView.delegate = self;
    self.collectionView.dataSource =self;
    self.collectionView.backgroundColor = [UIColor whiteColor];
//    self.collectionView.backgroundColor = [UIColor colorWithRed:0.948 green:1.000 blue:0.855 alpha:1.000];
    [self.collectionView registerClass:[PTDate class] forCellWithReuseIdentifier:@"reuse"];
    [self.scrollView addSubview:self.collectionView];
    
    [self xiangqingViews];
    [self otherViews];
    
}


- (void)xiangqingViews
{
    self.xqView = [[XQJSView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 500)];
    [self.collectionView addSubview:self.xqView];
}

- (void)otherViews
{
    self.otherView = [[OtherView alloc] initWithFrame:CGRectMake(0, 540, self.view.frame.size.width, 40)];
    [self.collectionView addSubview:self.otherView];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PTDate *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    [cell.dateImageView setImage:[UIImage imageNamed:@"like"]];
//    cell.dateImageView.backgroundColor = [UIColor redColor];
//    cell.xiangQingLabel.backgroundColor = [UIColor greenColor];
    cell.xiangQingLabel.text = @"高大上, 高品质, 高要求";
    cell.diDianLabel.text = @"哈尔滨";
//    cell.baoYouLabel.backgroundColor = [UIColor grayColor];
    cell.baoYouLabel.text = @"包邮";
//    cell.moneyLabel.backgroundColor = [UIColor redColor];
    cell.moneyLabel.text = @"1900.00";
    cell.backgroundColor = [UIColor colorWithRed:240/255.0 green:241/255.0 blue:242/255.0 alpha:1];
    
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    return CGSizeMake(self.view.frame.size.width, 590);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
